﻿@model dynamic
@{
    ViewBag.Title = Resources.MenuResource.TopMenu_CurrentStatus;
    ViewBag.CurrentMainMenu = 3;
}

<ul class="middle_menu">
    <li id="btnQQMonitor">
        <a href="@Url.Action("QQPasswordsManager", "QQMonitor")">
            <img src="@Url.Content("~/Content/images/middle_menu_icon_01.png")" alt="@Resources.MenuResource.MiddleMenu_QQMonitoring" />
            @Resources.MenuResource.MiddleMenu_QQMonitoring
        </a>
    </li>
    <li>
        <a href="@Url.Action("Index","VirusEmbeds")">
            <img src="@Url.Content("~/Content/images/middle_menu_icon_02.png")" alt="@Resources.MenuResource.MiddleMenu_VirusEmbeds" />
            @Resources.MenuResource.MiddleMenu_VirusEmbeds
        </a>
    </li>
    @*<li>
        <a href="javascript:;" onclick='$.openModalDialog("showdialog_Complex08.html",950,590)'>
            <img src="@Url.Content("~/Content/images/middle_menu_icon_03.png")" alt="@Resources.MenuResource.MiddleMenu_GetAEmailPassword" />
            @Resources.MenuResource.MiddleMenu_GetAEmailPassword
        </a>
    </li>*@
    <li>
        <a href="@Url.Action("WhiteListSet", "WhiteList")">
            <img src="@Url.Content("~/Content/images/middle_menu_icon_06.png")" alt="@Resources.MenuResource.MiddleMenu_MonitoringFilter" />
            @Resources.MenuResource.MiddleMenu_MonitoringFilter
            @*白名单*@
        </a>
    </li>
    @*<li>
        <a href="javascript:;">
            <img src="@Url.Content("~/Content/images/middle_menu_icon_04.png")" alt="@Resources.MenuResource.MiddleMenu_HTTPSMonitoring" />
            @Resources.MenuResource.MiddleMenu_HTTPSMonitoring
        </a>
    </li>
    <li>
        <a href="javascript:;">
            <img src="@Url.Content("~/Content/images/middle_menu_icon_05.png")" alt="@Resources.MenuResource.MiddleMenu_ProtocolBlocking" />
            @Resources.MenuResource.MiddleMenu_ProtocolBlocking
        </a>
    </li>
    <li>
        <a href="javascript:;">
            <img src="@Url.Content("~/Content/images/middle_menu_icon_07.png")" alt="@Resources.MenuResource.MiddleMenu_MonitoringSetting" />
            @Resources.MenuResource.MiddleMenu_MonitoringSetting
        </a>
    </li>*@
</ul>
<div class="middle_left">
    <div class="middle_left_title">
        <div id="openall">全部展开</div>
        <div id="closeall">全部收缩</div>
        <div id="arrow">
            <img src="@Url.Content("~/Content/images/middle_left_title_arrow.gif")" width="8" height="8" />
        </div>
    </div>
    <!--begin tree-->
    <ul id="middle_left_tree" class="ztree">
    </ul>
    <div class="tree_bottom_btn">
        <div id="refreshTree"><a href="javascript:;">刷新菜单</a></div>
        <div id="scan"><a href="#">扫描主机</a></div>
    </div>

</div>
<div class="middle_right">
    <iframe id="mainFrame" name="mainFrame" src="@Url.Action("DataRecordList")" allowtransparency="true" frameborder="0"></iframe>
</div>
<div class="ui-helper-clearfix ui-helper-hidden"></div>
@section css{
    <link type="text/css" rel="stylesheet" href="@Url.Content("~/Content/ztree/zTreeStyle.css")"/>
    <link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/themes/base/minified/jquery-ui.min.css")"/>

    <style type="text/css">
        .middle_left
        {
            position: absolute;
        }

        .centerContent
        {
            border-left: 1px solid #b1b1b1;
            position: absolute;
            right: 0;
            top: 0;
            width: 6px;
            height: 100%;
        }

        .centerBar
        {
            left: 0;
            right: 0;
            width: 100%;
            height: 100%;
            cursor: e-resize;
            background-color: #ebebeb;
            border: 1px solid #f1f1f1;
            border-bottom: 0;
            border-top: 0;
        }

        .middle_right iframe
        {
            position: absolute!important;
            _position: inherit;
            top: 0;
            bottom: 0;
            width: 100%;
            _width: 80%;
            height: 100%;
        }
        .ui-resizable-e
        {
            right: 0;
            width: 6px;
            background-color: #ebebeb;
            border: 1px solid #f1f1f1;
            -moz-user-select: none;
            -ms-user-select: none;
            -webkit-user-select: none;
            user-select: none;
        }
        .ui-resizable-e:hover {
            width: 12px;
        }
    </style>
}
@section javascript
{
    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery-ui-1.9.2.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/ztree/jquery.ztree.all-3.5.js")"></script>
    <script type="text/javascript">
        $(function () {
            $('.middle_left').resizable({
                minWidth: 210,
                maxWidth: 400,
                handles: 'e',
                resize: function (event, ui) {
                    $('.middle_right').css('left', ui.size.width + 5);
                },
                stop: function (event, ui) {
                    //重置middle_left的高度，否则改变浏览器窗口大小会出现middle_left的高度与浏览器高度不一致
                    ui.element.css({ 'height': 'auto', 'bottom': 0 });
                    $('.middle_right').css('left', ui.size.width + 5);
                }
            });
            var ztreeSets = {
                data: {
                    simpleData: {
                        pIdKey: 'ParentId',
                        rootPId: 0
                    }
                },
                edit: {
                    enable: true,
                    showRemoveBtn: false,
                    showRenameBtn: isShowEditBtn,
                    renameTitle: '重命名'
                },
                callback: {
                    onRename: onRename
                }
            };
            var zNodes = @Html.Raw(ViewBag.TreeData);
            
            $.fn.zTree.init($('#middle_left_tree'), ztreeSets, zNodes);
            $('#middle_left_tree').data('ztreeSets', ztreeSets);
            $('#openall').click(function () {
                var treeObj = $.fn.zTree.getZTreeObj("middle_left_tree");
                treeObj.expandAll(true);
            });
            $('#closeall').click(function () {
                var treeObj = $.fn.zTree.getZTreeObj("middle_left_tree");
                treeObj.expandAll(false);
            });
            $('.middle_menu li').click(function() {
                var $btn = $(this), url = $btn.find('a').attr('href');
                $.openModalDialog({
                    url: url,
                    width: '950px',
                    height: '610px',
                    scroll: false,
                    help: false
                });
                return false;
            });
            $('#scan').click(function() {
                $.openModalDialog({
                    url: '@Url.Action("HostScan","Task")',
                    width: '700px',
                    height: '610px',
                    scroll: false
                });
                return false;
            });
            $('#refreshTree').click(refreshTreeData);
            @Html.Partial("_ShowErrorMessage")
        });

        function addHoverDom(treeId, treeNode) {
            var sObj = $("#" + treeNode.tId + "_span");
            if (treeNode.editNameFlag || $("#addBtn_" + treeNode.id).length > 0) return;
            var addStr = "<span class='button add' id='addBtn_" + treeNode.id
                + "' title='add node' onfocus='this.blur();'></span>";
            sObj.after(addStr);
        }

        function isShowEditBtn(treeId, treeNode) {
            return treeNode && treeNode.expandos && (treeNode.expandos.isHost || treeNode.expandos.isKeyword);
        }

        function onRename(event, treeId, treeNode) {
            if (!treeNode.expandos) return true;
            if (treeNode.name == '') return false;
            $.ajax({
                url: '@Url.Action("Rename", "Host")',
                cache: false,
                type: 'post',
                dataType: 'json',
                data: { hostId: treeNode.expandos.hostId, hostName: treeNode.name },
                success: function (result) {
                    if (!result || !result.success) {
                        alert(result.message);
                    }
                }
            });
        }

        function loadFrame(url) {
            $('#mainFrame').attr('src', url);
        }

        function refreshTreeData() {
            $.showLoading('正在刷新，请等待');
            $.ajax({
                url: '@Url.Action("ReGenerateTree")',
                cache: false,
                dataType: 'json',
                success: function(treeNodes) {
                    if (treeNodes) {
                        $.fn.zTree.destroy('middle_left_tree');
                        var $tree = $('#middle_left_tree'), ztreeSets = $tree.data('ztreeSets');
                        $.fn.zTree.init($tree, ztreeSets, treeNodes);
                    }
                    $.hideLoading();
                }
            });
        }
    </script>
}
